/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package futbolpredictor;

import java.io.File;
import java.io.RandomAccessFile;

/**
 *
 * @author Rodrigo
 */
public class Main {

	/**
	 * @param args the command line arguments
	 */
	public static void main(String[] args) {
		try {
			String htmlTrain = "uru2010.html";
			String htmlTest = "uru2011.html";
			String archTrain = "entrenamiento.csv";
			File target = new File("entrenamiento.csv");
			RandomAccessFile file = new RandomAccessFile(target, "rwd");
			file.setLength(0);
			file.close();
			String archTrainPreProc = "training_set_final.txt";
			String archTest = "test.csv";
			target = new File("test.csv");
			file = new RandomAccessFile(target, "rwd");
			file.setLength(0);
			file.close();
			String archTestPreProc = "evaluation_set_final.txt";
			boolean desdeHTML = false;
			if (!(args.length < 1)) {
				if (args[0].equals("html")) {
					desdeHTML = true;
				}
			}


			if (desdeHTML) {
				PreProcesador pre = new PreProcesador(htmlTrain);
				pre.guardarCSV(archTrain);
				pre = new PreProcesador("uru09.html");
				pre.guardarCSV(archTrain);
				pre = new PreProcesador("uru08.html");
				pre.guardarCSV(archTrain);
				pre = new PreProcesador("uru07.html");
				pre.guardarCSV(archTrain);
				pre = new PreProcesador("uru06.html");
				pre.guardarCSV(archTrain);
				pre = new PreProcesador("uru04.html");
				pre.guardarCSV(archTrain);
				pre = new PreProcesador(htmlTest);
				pre.guardarCSV(archTest);

				PostProcesador post = new PostProcesador(archTrain, 1990, 2008);
				post.guardarCSV(archTrain);

				post = new PostProcesador(archTest, 2007, 2011);
				post.guardarCSV(archTest);
			} else {
				PostProcesador post = new PostProcesador(archTrainPreProc, 2006, 2008);
				post.guardarCSV(archTrain);

				post = new PostProcesador(archTestPreProc, 2007, 2011);
				post.guardarCSV(archTest);
			}
			Clasificador clasif = new Clasificador(archTrain, archTest);
			clasif.crearModelo();
			clasif.clasificar();

		} catch (Exception e) {
			System.out.println(e.toString());
		}
	}
}
